package bpm.dao.impl.process;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bpm.domain.process.Actor;
import bpm.domain.process.ActorStruct;
import bpm.domain.process.ActorType;
import bpm.domain.process.ActorVar;

public class ActorMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		Actor actor = new Actor();
		
		actor.setProcessDefinitionId(rs.getString("procdef_id"));
		actor.setNodeId("node_id");
		actor.setRoleId(rs.getString("role_id"));
		actor.setScope(rs.getString("scope"));
		actor.setLevel(rs.getInt("level"));
		actor.setActorVar(ActorVar.keyOf(rs.getString("actor_var")));
		if(rs.getString("actor_type") != null) {
			actor.setActorType(ActorType.valueOf(rs.getString("actor_type")));
		}
		if(rs.getString("actor_struct") != null) {
			actor.setActorStruct(ActorStruct.valueOf(rs.getString("actor_struct")));
		}
		actor.setMultipleString(rs.getString("multiple"));
		
		return actor;
	}

}
